
var Content=React.createClass({displayName: "Content",
	getInitialState:function(){
		var contentData=this.props.options.contentData || {};

		return {
			name:contentData.name || '',
			description:contentData.description || '',
			logo:contentData.logo || '',
			qrCode:contentData.qrCode || ''
		}
	},
	changeName:function(e){
		this.setState({
			name:e.target.value
		})
	},
	changeDesc:function(e){
		this.setState({
			description:e.target.value
		})
	},
	changeLogo:function(e){
		var self=this,
			reader=new FileReader();
		reader.onload=function(){
			self.setState({
				tempLogo:this.result,
				logo:e.target.files[0]
			})
		}
		reader.readAsDataURL(e.target.files[0])
	},
	changeQrcode:function(e){
		var self=this,
			reader=new FileReader();
		reader.onload=function(){
			self.setState({
				tempQrCode:this.result,
				qrCode:e.target.files[0]
			})
		}
		reader.readAsDataURL(e.target.files[0])
	},
	submit:function(){
		var state=this.state;
		if(state.name){
			$(this.refs.form).submit()
		}else{
			alert('请输入照片墙名称')
		}
	},
	render:function(){
		var options=this.props.options,
			socialAccount=options.socialAccount,
			contentData=options.contentData || {},
			state=this.state;

		return (
			React.createElement("div", null, 
				React.createElement("section", {className: "content-header"}, 
					React.createElement("h1", null, contentData.id?'编辑照片墙':'新建照片墙', React.createElement("small", null, socialAccount.name), React.createElement("a", {className: "pull-right", href: "index.html"}, "返回"))
				), 
				React.createElement("div", {className: "content"}, 
		            React.createElement("div", {className: "row"}, 
		                React.createElement("div", {className: "col-md-12 wall-box"}, 
		                    React.createElement("div", {className: "box box-flat box-solid form-box"}, 
		                    	React.createElement("div", {className: "box-body"}, 
		                    		React.createElement("div", {className: "col-sm-10"}, 
		                    			React.createElement("div", {className: "form-group"}, 
											React.createElement("h4", null, "照片墙名称"), 
											React.createElement("input", {type: "text", className: "form-control", placeholder: "请输入照片墙名称", value: state.name, onChange: this.changeName})
										), 
										React.createElement("div", {className: "form-group"}, 
											React.createElement("h4", null, "照片墙描述"), 
											React.createElement("textarea", {className: "form-control", rows: "6", placeholder: "请输入照片墙描述，最多140字", maxLength: "140", value: state.description, onChange: this.changeDesc})
										)
		                    		), 
		                    		React.createElement("div", {className: "col-sm-2"}, 
		                    			React.createElement("div", {className: "form-group photo_upload_box"}, 
		                    				React.createElement("label", {htmlFor: "uploadLogo"}, 
		                    					React.createElement("div", {className: "photo_upload"}, contentData.logo || state.tempLogo?React.createElement("img", {src: contentData.logo || state.tempLogo}):''), 
												React.createElement("div", {className: "btn btn-flat btn-xs btn-primary"}, "上传Logo"), 
												React.createElement("input", {id: "uploadLogo", type: "file", onChange: this.changeLogo})
		                    				)
										), 
										React.createElement("div", {className: "form-group photo_upload_box"}, 
											React.createElement("label", {htmlFor: "uploadQrcode"}, 
												React.createElement("div", {className: "photo_upload"}, contentData.qrCode || state.tempQrCode?React.createElement("img", {src: contentData.qrCode || state.tempQrCode}):''), 
												React.createElement("div", {className: "btn btn-flat btn-xs btn-primary"}, "上传二维码"), 
												React.createElement("input", {id: "uploadQrcode", type: "file", onChange: this.changeQrcode})
											)
										)
		                    		)
		                    	), 
		                    	React.createElement("div", {className: "box-footer"}, 
		                    		React.createElement("form", {ref: "form", encType: "multipart/form-data", action: "#"}, 
		                    			React.createElement("input", {type: "hidden", name: "id", value: state.id}), 
		                    			React.createElement("input", {type: "hidden", name: "name", value: state.name}), 
		                    			React.createElement("input", {type: "hidden", name: "description", value: state.description}), 
		                    			React.createElement("input", {type: "hidden", name: "logo", value: state.logo}), 
		                    			React.createElement("input", {type: "hidden", name: "qrCode", value: state.qrCode})
		                    		), 
		                    		React.createElement("button", {type: "submit", onClick: this.submit, className: "btn btn-flat btn-primary pull-right"}, contentData?'保 存':'创 建')
		                    	)
		                    )
		                )
		            )
		        )
	        )
		)
	}
})
